Handle reparsing any strings if the theme changes. (#69465)
authorOwen Taylor <otaylor@redhat.com>
Fri, 1 Feb 2002 20:14:02 +0000 (20:14 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Fri, 1 Feb 2002 20:14:02 +0000 (20:14 +0000)
Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>

        * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
        any strings if the theme changes. (#69465)

        * tests/testgtk.c: Add a test for gtk_rc_parse_string().

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkrc.c
tests/testgtk.c

index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index 8440e123745b5b3f1a2e9210b93f2922d9155478..9de966b625f114961914d692f72cf031c6211ffc 100644 (file)
@@ -1,3 +1,10 @@
+Fri Feb  1 14:50:36 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkrc.c (gtk_rc_parse_string): Handle reparsing
+       any strings if the theme changes. (#69465)
+
+       * tests/testgtk.c: Add a test for gtk_rc_parse_string().
+
 Fri Feb  1 20:50:29 2002  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreeview.c (gtk_tree_view_dy_to_top_row): set tree to
index a4f64c3011a8f7c2f1825d0e0b43335fa51b79f4..3324a79e1c09f811686df982ec4a1dcc16329c1e 100644 (file)
@@ -74,6 +74,7 @@ struct _GtkRcSet
 
 struct _GtkRcFile
 {
+  gboolean is_string;          /* If TRUE, name is a string to parse with gtk_rc_parse_string() */
   time_t mtime;
   gchar *name;
   gchar *canonical_name;
@@ -784,10 +785,24 @@ _gtk_rc_init (void)
 void
 gtk_rc_parse_string (const gchar *rc_string)
 {
+  GtkRcFile *rc_file;
+  /* This is wrong; once we have meaingful RC context, we need to parse the
+   * string in all contexts, and in fact, in future contexts as well.
+   */
+  GtkRcContext *context = gtk_rc_context_get (gtk_settings_get_default ());
+      
   g_return_if_fail (rc_string != NULL);
 
-  gtk_rc_parse_any (gtk_rc_context_get (gtk_settings_get_default ()),
-                   "-", -1, rc_string);        /* FIXME */
+  rc_file = g_new (GtkRcFile, 1);
+  rc_file->is_string = TRUE;
+  rc_file->name = g_strdup (rc_string);
+  rc_file->canonical_name = NULL;
+  rc_file->mtime = 0;
+  rc_file->reload = TRUE;
+
+  context->rc_files = g_slist_append (context->rc_files, rc_file);
+
+  gtk_rc_parse_any (context, "-", -1, rc_string);
 }
 
 static void
@@ -819,6 +834,7 @@ gtk_rc_parse_file (GtkRcContext *context,
   if (!tmp_list)
     {
       rc_file = g_new (GtkRcFile, 1);
+      rc_file->is_string = FALSE;
       rc_file->name = g_strdup (filename);
       rc_file->canonical_name = NULL;
       rc_file->mtime = 0;
@@ -1325,12 +1341,15 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
       while (tmp_list)
        {
          rc_file = tmp_list->data;
-         
-         if (!lstat (rc_file->name, &statbuf) && 
-             (statbuf.st_mtime > rc_file->mtime))
+
+         if (!rc_file->is_string)
            {
-             mtime_modified = TRUE;
-             break;
+             if (!lstat (rc_file->name, &statbuf) && 
+                 (statbuf.st_mtime > rc_file->mtime))
+               {
+                 mtime_modified = TRUE;
+                 break;
+               }
            }
          
          tmp_list = tmp_list->next;
@@ -1354,7 +1373,12 @@ gtk_rc_reparse_all_for_settings (GtkSettings *settings,
        {
          rc_file = tmp_list->data;
          if (rc_file->reload)
-           gtk_rc_parse_file (context, rc_file->name, GTK_PATH_PRIO_RC, TRUE);
+           {
+             if (rc_file->is_string)
+               gtk_rc_parse_string (rc_file->name);
+             else
+               gtk_rc_parse_file (context, rc_file->name, GTK_PATH_PRIO_RC, TRUE);
+           }
 
          if (rc_file->canonical_name != rc_file->name)
            g_free (rc_file->canonical_name);
index 667eef04424170fd3a05ea65ccbf0324c4fcdf18..f60fd6fa58460de59a24438730c945fce2284bcd 100644 (file)
@@ -11033,6 +11033,7 @@ create_main_window (void)
 
   label = gtk_label_new (buffer);
   gtk_box_pack_start (GTK_BOX (box1), label, FALSE, FALSE, 0);
+  gtk_widget_set_name (label, "testgtk-version-label");
 
   scrolled_window = gtk_scrolled_window_new (NULL, NULL);
   gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 10);
@@ -11263,7 +11264,17 @@ main (int argc, char *argv[])
                                "debug_msg",
                                1,
                                GTK_TYPE_STRING, "GtkWidgetClass <ctrl><release>9 test");
+  
+  /* We use gtk_rc_parse_string() here so we can make sure it works across theme
+   * changes
+   */
 
+  gtk_rc_parse_string ("style \"testgtk-version-label\" { "
+                      "   fg[NORMAL] = \"#ff0000\"\n"
+                      "   font = \"Sans 18\"\n"
+                      "}\n"
+                      "widget \"*.testgtk-version-label\" style \"testgtk-version-label\"");
+  
   create_main_window ();
 
   gtk_main ();